#define _CRT_SECURE_NO_WARNINGS 0
#include"RBTree.h"
typedef RBTree<egghead::string, int>tree1;
typedef RBTree<int, int>tree2;
void test01()
{
	//tree1 t("32r2f", 12);
	tree1 t;
	pair<egghead::string, int>p("1323", 1121);
	auto& _p = p;
	t.insert(move(_p));
}

void test02()
{
	tree2 t;
	for (int i = 0; i < 14; i++)
		t.insert(i, i);
	t.levelorder();
	t.levelorder();
	//t.showtrace();
	t.inorder();
}
void test03()
{
	tree2 t;
	//int arr[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	int arr[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto num : arr)
		t.insert(num,num);
	for (int i = 1000; i > 0; i--)
		t.insert(i, i);
	t.levelorder();
	t.levelorder();
	t.inorder();
	bool flag = t.checktree();
	if (flag)
		cout << "----Correct----" << endl;
	else
		cout << "----Error----" << endl;
}

void test04()
{
	srand(time(0));
	tree2 t;
	const int N = 100000;
	vector<int>a(N);
	int begin1 = clock();
	for (int i = 0; i < N; i++)
		a.push_back(i + rand()%N + 1);
	int end1 = clock();
	cout << "vector::push_back:" << end1 - begin1<<endl;

	int begin2 = clock();
	for (auto num : a)
		t.insert(num, num);
	int end2 = clock();
	cout << "RBTree::insert:" << end2 - begin2<<endl;
	printf("---------------------------------\n");
	cout << "RBTree node number:" << t.size() << endl;
	cout << "RBTree leaf number:" << t.leafsize()<<endl;
	//t.inorder();
	int begin3 = clock();
	bool flag = t.checktree();
	int end3 = clock();
	if (flag)
		cout << "RBTree Correct" << endl;
	else
		cout << "RBTree Error" << endl;
	cout << "RBTree::checktree:" << end3 - begin3<<endl;
	//t.levelorder();

}

struct mytest
{

	int a = 0;
	mytest() = default;
};

void test05()
{
	vector<mytest>v{ {1},{2},{3} };
	auto l = v.begin();
	cout << l.operator->()->a;
}


int main()
{
	//test01();
	//test02();
	//test03();
	//test04();
	test05();
	return 0;
}




//template<class T>
//T& fun(T&& i)
//{
//	return i + 12;
//}
//void test01()
//{
//	int i = 0;
//	cout<<fun(i);
//}